﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Collections;
//using System.Windows;
//using HalconDotNet;
//using Project1.Common;
//using Point = Project1.Element.Point;

//namespace Project1.Element
//{
//    public class Plan
//    {
//        private static GeoMethod supTools = new GeoMethod();
//        public static int measure_count = 0;
//        private int planType;
//        private string name;
//        private Hashtable args;
//        private HObject ROI_XLD;
//        private Utils utils = new Utils();
//        private List<Point> pointList;
//        private List<Line> lineList;
//        private List<Circle> circleList;
//        private List<string> objectNameCollection;
//        private Point leftPoint,rightPoint;
//        private Line leftLine, rightLine;
//        private Circle leftCircle, rightCircle;

        
//        public Plan(int planType, Hashtable args,HObject ROI_XLD)
//        {

//            this.planType = planType;
//            this.ROI_XLD = new HObject(ROI_XLD);
//            this.args = new Hashtable();
//            this.args.Clear();
//            IDictionaryEnumerator ie = args.GetEnumerator();
//            while (ie.MoveNext())
//            this.args.Add(ie.Key, ie.Value);
//            this.name = "ROI" + measure_count.ToString();
//            measure_count++;
//        }

//        public Plan(Plan plan)
//        {
//            this.planType = plan.planType;
//            this.ROI_XLD = new HObject(plan.ROI_XLD);
//            this.args = new Hashtable();
//            this.args.Clear();
//            IDictionaryEnumerator ie = plan.args.GetEnumerator();
//            while (ie.MoveNext())
//                this.args.Add(ie.Key, ie.Value);
//            this.name = plan.name;
//        }


//        public Plan(List<string> objectNameCollection,int planType)
//        {
//            if (this.objectNameCollection == null) this.objectNameCollection = new List<string>();
//            foreach(var element in objectNameCollection)
//            {
//                this.objectNameCollection.Add(element);
//            }
//            this.planType = planType;
//        }
   
//        public Plan(int planType,HTuple min_radius, HTuple max_radius, HTuple min_threshold, HTuple max_threshold, HObject ROI_XLD)
//        {
//            this.args = new Hashtable();
//            var generatedArgs =  generateHashtableForCircle(min_radius, max_radius, min_threshold, max_threshold);
//            IDictionaryEnumerator ie = generatedArgs.GetEnumerator();
//            while (ie.MoveNext())this.args.Add(ie.Key, ie.Value);
//            this.planType = planType;
//            this.ROI_XLD = new HObject(ROI_XLD);
//            this.name = "ROI" + measure_count.ToString();
//            measure_count++;
//        }

//        public Plan(int planType,  HTuple min_threshold, HTuple max_threshold, HObject ROI_XLD)
//        {
//            this.args = new Hashtable();
//            var generatedArgs = generateHashtableForLine( min_threshold, max_threshold);
//            IDictionaryEnumerator ie = generatedArgs.GetEnumerator();
//            while (ie.MoveNext()) this.args.Add(ie.Key, ie.Value);
//            this.planType = planType;
//            this.ROI_XLD = new HObject(ROI_XLD);
//            this.name = "ROI" + measure_count.ToString();
//            measure_count++;
//        }

//        public Plan(int planType, HTuple mode, HObject ROI_XLD, HTuple minThreshold, HTuple maxThreshold)
//        {
//            this.args = new Hashtable();
//            var generatedArgs = generateHashtableForPoint(mode, minThreshold, maxThreshold);
//            IDictionaryEnumerator ie = generatedArgs.GetEnumerator();
//            while (ie.MoveNext()) this.args.Add(ie.Key, ie.Value);
//            this.planType = planType;
//            this.ROI_XLD = new HObject(ROI_XLD);
//            this.name = "ROI" + measure_count.ToString();
//            measure_count++;
//        }

       
       
//        public Output Execute(HObject image,HTuple homMat2D)
//        {
//            //执行第一类任务所需参数
//            HObject hv_TransROI , region = null;
//            Output outPut = null;
//            Circle circle = null;
//            Point point = null;
//            Line line = null;
//            HOperatorSet.GenEmptyObj(out hv_TransROI);
//            HOperatorSet.AffineTransContourXld(this.ROI_XLD, out hv_TransROI, homMat2D);
//            HOperatorSet.GenRegionContourXld(hv_TransROI, out region, new HTuple("filled"));

//            //执行第二第三类任务所需参数
//            HObject contourTuple = null, midLineContours = null, parallelContours = null, verticalLineContours = null, fitLineContours = null;
//            HTuple hv_Row, hv_Column, hv_Radius;
//            HTuple tempRow = null, tempColumn = null;
//            HObject concatLine = null;
//            HTuple minDist, maxDist;
//            HTuple rowBegin, colBegin, rowEnd, colEnd, nr, nc, dist;
//            List<Point> tempPoints = new List<Point>();
//            List<Line> tempLines = new List<Line>();

            



//            switch (this.planType)
//            {

//                case ConstValue.MEASURE_CIRCLE:
//                    circle = get_circle(image, region);
//                    if (circle == null) return null;
//                    outPut = new Output(circle, ConstValue.CIRCLE);
//                    break;
//                case ConstValue.MEASURE_CIRCLE2:
//                    if (circle == null) return null;
//                    circle = get_circle(image, region);
//                    outPut = new Output(circle, ConstValue.CIRCLE);
//                    break; 
//                case ConstValue.MEASURE_LINE:
//                    if (line == null) return null;
//                    line = get_line(image, region);
//                    outPut = new Output(line, ConstValue.LINE);
//                    break;
//                case ConstValue.MEASURE_LINE_PEAK:
//                    line = get_line(image, region);
//                    if (line == null) return null;
//                    outPut = new Output(line, ConstValue.LINE);
//                    break;
//                case ConstValue.MEASURE_POINT:
//                    point = Get_Point(image, hv_TransROI);
//                    if (point == null) return null;
//                    outPut = new Output(point, ConstValue.POINT);
//                    break;
//                case ConstValue.MEASURE_POINT_PEAK:
//                    point = Get_peakPoint(image, region);
//                    if (point == null) return null;
//                    outPut = new Output(point, ConstValue.POINT);
//                    break;
//                case ConstValue.MEASURE_ARC_ANGLE:
//                    if (objectNameCollection == null) return null;
//                    Line arc = Line.FindItemByName(objectNameCollection[0], lineList);
//                    HTuple row, column, radius, startPhi, endPhi, order;
//                    HOperatorSet.FitCircleContourXld(arc.LineContours, "algebraic", -1, 0.0, 0, 3, 2.0, out row, out column, out radius, out startPhi, out endPhi, out order);
//                    outPut = new Output((double)(endPhi - startPhi), ConstValue.ANGLE);
//                    break;
//                case ConstValue.MEASURE_Arc_Concat:
//                    if (objectNameCollection == null) return null;
//                    List<Line> list = new List<Line>();
//                    foreach (var item in objectNameCollection)
//                    {
//                        Line temp = Line.FindItemByName(item, lineList);
//                        if (contourTuple == null)
//                        {
//                            contourTuple = new HObject(temp.LineContours);
//                        }
//                        else
//                        {
//                            contourTuple.ConcatObj(temp.LineContours);
//                        }
//                    }
//                    HObject ho_Circle;
//                    GeoMethod.Arc_Concat(contourTuple, out ho_Circle, out hv_Row, out hv_Column, out hv_Radius);
//                    outPut = new Output(new Circle(new Point(hv_Row, hv_Column), hv_Radius, ho_Circle), ConstValue.CIRCLE);
//                    break;
//                case ConstValue.MEASURE_CC_Cross:
//                    if (objectNameCollection == null) return null;
                
//                    GeoMethod.CC_Cross(leftCircle.CircleContours, rightCircle.CircleContours, out hv_Row, out hv_Column);

//                    for (int i = 0; i < hv_Row.TupleLength(); i++)
//                    {
//                        tempPoints.Add(new Point(hv_Row[i], hv_Column[i]));
//                    }
//                    outPut = new Output(tempPoints, ConstValue.POINT);
//                    break;
//                case ConstValue.MEASURE_CC_DIST:
//                    if (objectNameCollection == null) return null;
//                    leftCircle = Circle.FindItemByName(objectNameCollection[0], circleList);
//                    rightCircle = Circle.FindItemByName(objectNameCollection[1], circleList);
//                    HOperatorSet.DistanceCc(leftCircle.CircleContours, rightCircle.CircleContours, "point_to_point", out minDist, out maxDist);
//                    double[] rs1 = { (double)minDist, (double)maxDist };
//                    outPut = new Output(rs1, ConstValue.DISTANCE);
//                    break;
//                case ConstValue.MEASURE_CC_Mid:
//                    if (objectNameCollection == null) return null;
//                    leftCircle = Circle.FindItemByName(objectNameCollection[0], circleList);
//                    rightCircle = Circle.FindItemByName(objectNameCollection[1], circleList);
//                    HObject midCircleContour;
//                    supTools.CC_Mid(leftCircle.CircleContours, rightCircle.CircleContours, out midCircleContour, out hv_Row, out hv_Column, out hv_Radius);
//                    outPut = new Output(new Circle(new Point(hv_Row, hv_Column), hv_Radius, midCircleContour), ConstValue.LINE);
//                    break;

//                case ConstValue.MEASURE_C_Fit:
//                    if (objectNameCollection == null) return null;
//                    leftCircle = Circle.FindItemByName(objectNameCollection[0], circleList);
//                    HObject fitCircleContours;
//                    HOperatorSet.GetContourXld(leftCircle.CircleContours, out tempRow, out tempColumn);
//                    supTools.C_Fit(out fitCircleContours, tempRow, tempColumn, out hv_Row, out hv_Column, out hv_Radius);
//                    outPut = new Output(new Circle(new Point(hv_Row, hv_Column), hv_Radius, fitCircleContours), ConstValue.CIRCLE);
//                    break;
//                case ConstValue.MEASURE_C_RADIUS:
//                    if (objectNameCollection == null) return null;
//                    leftCircle = Circle.FindItemByName(objectNameCollection[0], circleList);
//                    outPut = new Output(leftCircle.Radius, ConstValue.RADIUS);
//                    break;
//                case ConstValue.MEASURE_C_SUP:
//                    HObject circleContours;
//                    //待修正
//                    supTools.C_SUP(out circleContours, 0, 0, 0);
//                    break;
//                case ConstValue.MEASURE_LC_Cross:
//                    if (objectNameCollection == null) return null;
//                    leftLine = Line.FindItemByName(objectNameCollection[0], lineList);
//                    rightCircle = Circle.FindItemByName(objectNameCollection[1], circleList);
//                    supTools.LC_Cross(leftLine.LineContours, rightCircle.CircleContours, out hv_Row, out hv_Column);

//                    for (int i = 0; i < hv_Row.TupleLength(); i++)
//                    {
//                        tempPoints.Add(new Point(hv_Row[i], hv_Column[i]));
//                    }
//                    outPut = new Output(tempPoints, ConstValue.POINT);
//                    break;
//                case ConstValue.MEASURE_LC_DIST:
//                    if (objectNameCollection == null) return null;
//                    leftLine = Line.FindItemByName(objectNameCollection[0], lineList);
//                    rightCircle = Circle.FindItemByName(objectNameCollection[1], circleList);
//                    HOperatorSet.FitLineContourXld(leftLine.LineContours, "turkey", -1, 0, 5, 2.0, out rowBegin, out colBegin, out rowEnd, out colEnd, out nr, out nc, out dist);
//                    HOperatorSet.DistanceLc(rightCircle.CircleContours, rowBegin, colBegin, rowEnd, colEnd, out minDist, out maxDist);
//                    double[] rs2 = { minDist, maxDist };
//                    outPut = new Output(rs2, ConstValue.DISTANCE);
//                    break;
//                case ConstValue.MEASURE_LL_Concate:
//                    if (objectNameCollection == null) return null;
//                    foreach (var name in objectNameCollection)
//                    {
//                        line = Line.FindItemByName(name, lineList);
//                        if (contourTuple == null)
//                        {
//                            contourTuple = new HObject(line.LineContours);
//                        }
//                        else
//                        {
//                            contourTuple.ConcatObj(line.LineContours);
//                        }
//                    }

//                    supTools.LL_Concate(contourTuple, out concatLine, out rowBegin, out colBegin, out rowEnd, out colEnd);
//                    outPut = new Output(new Line(new Point(rowBegin, colBegin), new Point(rowEnd, colEnd)), ConstValue.LINE);
//                    break;
//                case ConstValue.MEASURE_LL_Cross:
//                    if (objectNameCollection == null) return null;
//                    leftLine = Line.FindItemByName(objectNameCollection[0], lineList);
//                    rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//                    supTools.LL_Cross(leftLine.LineContours, rightLine.LineContours, out hv_Row, out hv_Column);
//                    outPut = new Output(new Point(hv_Row, hv_Column), ConstValue.POINT);
//                    break;
//                case ConstValue.MEASURE_LL_Dist:
//                    if (objectNameCollection == null) return null;
//                    leftLine = Line.FindItemByName(objectNameCollection[0], lineList);
//                    rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//                    HTuple distance;
//                    supTools.LL_Dist(leftLine.LineContours, rightLine.LineContours, out distance);
//                    outPut = new Output((double)distance, ConstValue.DISTANCE);
//                    break;
//                case ConstValue.MEASURE_LL_InnerC:
//                    if (objectNameCollection == null) return null;
//                    foreach (var name in objectNameCollection)
//                    {
//                        line = Line.FindItemByName(name, lineList);
//                        if (contourTuple == null)
//                        {
//                            contourTuple = new HObject(line.LineContours);
//                        }
//                        else
//                        {
//                            contourTuple.ConcatObj(line.LineContours);
//                        }
//                    }

//                    supTools.LL_InnerC(contourTuple, out circleContours, out hv_Row, out hv_Column, out hv_Radius);
//                    outPut = new Output(new Circle(new Point(hv_Row, hv_Column), hv_Radius, circleContours), ConstValue.CIRCLE);
//                    break;
//                case ConstValue.MEASURE_LL_Mid:
//                    if (objectNameCollection == null) return null;
//                    leftLine = Line.FindItemByName(objectNameCollection[0], lineList);
//                    rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//                    supTools.LL_Mid(leftLine.LineContours, rightLine.LineContours, out midLineContours, out rowBegin, out colBegin, out rowEnd, out colEnd);
//                    outPut = new Output(new Line(new Point(rowBegin, colBegin), new Point(rowEnd, colEnd)), ConstValue.LINE);
//                    break;
//                case ConstValue.MEASURE_PC_DIST:
//                    if (objectNameCollection == null) return null;
//                    leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//                    rightCircle = Circle.FindItemByName(objectNameCollection[1], circleList);
//                    HOperatorSet.DistancePc(rightCircle.CircleContours, leftPoint.Row, leftPoint.Column, out minDist, out maxDist);
//                    double[] rs = { minDist, maxDist };
//                    outPut = new Output(rs, ConstValue.DISTANCE);
//                    break;
//                case ConstValue.MEASURE_PL_DIST:
//                    if (objectNameCollection == null) return null;
//                    leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//                    rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//                    HOperatorSet.FitLineContourXld(rightLine.LineContours, "turkey", -1, 0, 5, 2.0, out rowBegin, out colBegin, out rowEnd, out colEnd, out nr, out nc, out dist);
//                    HOperatorSet.DistancePl(leftPoint.Row, leftPoint.Column, rowBegin, colBegin, rowEnd, colEnd, out distance);
//                    outPut = new Output((double)distance, ConstValue.DISTANCE);
//                    break;
//                case ConstValue.MEASURE_PL_Mid:
//                    if (objectNameCollection == null) return null;
//                    leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//                    rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//                    supTools.PL_Mid(rightLine.LineContours, out midLineContours, leftPoint.Row, leftPoint.Column, out rowBegin, out colBegin, out rowEnd, out colEnd);
//                    outPut = new Output(new Line(rowBegin, colBegin, rowEnd, colEnd), ConstValue.LINE);
//                    break;
//                case ConstValue.MEASURE_PL_Parallel:
//                    if (objectNameCollection == null) return null;
//                    leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//                    rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//                    supTools.PL_Parallel(rightLine.LineContours, leftPoint.Row, leftPoint.Column, out parallelContours, out rowBegin, out colBegin, out rowEnd, out colEnd);
//                    outPut = new Output(new Line(rowBegin, colBegin, rowEnd, colEnd), ConstValue.LINE);
//                    break;
//                case ConstValue.MEASURE_PL_VERTICAL:
//                    if (objectNameCollection == null) return null;
//                    leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//                    rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//                    supTools.PL_VERTICAL(rightLine.LineContours, out verticalLineContours, leftPoint.Row, leftPoint.Column, out rowBegin, out colBegin, out rowEnd, out colEnd);
//                    outPut = new Output(new Line(rowBegin, colBegin, rowEnd, colEnd), ConstValue.LINE);
//                    break;

//                case ConstValue.MEASURE_PP_DIST:
//                    if (objectNameCollection == null) return null;
//                    leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//                    rightPoint = Point.FindItemByName(objectNameCollection[1], pointList);
//                    HOperatorSet.DistancePp(leftPoint.Row, leftPoint.Column, rightPoint.Row, rightPoint.Column, out distance);
//                    outPut = new Output((double)distance, ConstValue.DISTANCE);
//                    break;
//                case ConstValue.MEASURE_PP_Mid:
//                    if (objectNameCollection == null) return null;
//                    leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//                    rightPoint = Point.FindItemByName(objectNameCollection[1], pointList);
//                    supTools.PP_Mid(out midLineContours, leftPoint.Row, leftPoint.Column, rightPoint.Row, rightPoint.Column, out rowBegin, out colBegin, out rowEnd, out colEnd);
//                    outPut = new Output(new Line(rowBegin, colBegin, rowEnd, colEnd), ConstValue.LINE);
//                    break;
//                case ConstValue.MEASURE_P_FitLine:
//                    if (objectNameCollection == null) return null;
//                    foreach (var name in objectNameCollection)
//                    {
//                        point = Point.FindItemByName(name, pointList);
//                        if (tempRow == null)
//                        {
//                            tempRow = new HTuple(point.Row);
//                            tempColumn = new HTuple(point.Column);
//                        }
//                        else
//                        {
//                            tempRow.TupleConcat(point.Row);
//                            tempColumn.TupleConcat(point.Column);
//                        }
//                    }
//                    supTools.P_FitLine(out fitLineContours, tempRow, tempColumn, out rowBegin, out colBegin, out rowEnd, out colEnd);
//                    break;
//                case ConstValue.MEASURE_P_Mid:
//                    if (objectNameCollection == null) return null;
//                    leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//                    rightPoint = Point.FindItemByName(objectNameCollection[1], pointList);

//                    break;
//            }
//            //HOperatorSet.SetColor(Utils.hv_ExpDefaultWinHandle, "yellow");
//            //HOperatorSet.SetLineWidth(Utils.hv_ExpDefaultWinHandle, new HTuple(3));
     
//           // HOperatorSet.GenRegionContourXld(hv_TransROI, out region, new HTuple("margin"));
//            //HOperatorSet.DispObj(hv_TransROI, Utils.hv_ExpDefaultWinHandle);
//            //MessageBox.Show("画了");
//            return outPut;
//        }

//        public void InitSrc(List<Point>pointList, List<Line> lineList,List<Circle>circleList)
//        {
//            this.pointList = pointList;
//            this.lineList = lineList;
//            this.circleList = circleList;
//        }
//        //public PlanElement ExecuteNext()
//        //{
//        //    PlanElement outPut = null;
//        //    HObject contourTuple = null, midLineContours = null, parallelContours = null, verticalLineContours = null, fitLineContours = null;
//        //    HTuple hv_Row, hv_Column, hv_Radius;
//        //    HTuple tempRow = null, tempColumn = null;
//        //    HObject concatLine = null;
//        //    HTuple minDist, maxDist;
//        //    HTuple rowBegin, colBegin, rowEnd, colEnd, nr, nc, dist;
//        //    List<Point> tempPoints = new List<Point>();
//        //    List<Line> tempLines = new List<Line>();
//        //    if (objectNameCollection == null) return null;
//        //    switch (planType)
//        //    {
//        //        case ConstValue.MEASURE_ARC_ANGLE:
//        //            Line arc = Line.FindItemByName(objectNameCollection[0], lineList);
//        //            HTuple row, column, radius, startPhi, endPhi, order;
//        //            HOperatorSet.FitCircleContourXld(arc.LineContours, "algebraic", -1, 0.0, 0, 3, 2.0, out row, out column, out radius, out startPhi, out endPhi, out order);
//        //            outPut = new PlanElement((double)(endPhi - startPhi), ConstValue.ANGLE);
//        //            break;
//        //        case ConstValue.MEASURE_Arc_Concat:
//        //            List<Line> list = new List<Line>();

//        //            foreach (var item in objectNameCollection)
//        //            {
//        //                Line temp = Line.FindItemByName(item, lineList);
//        //                if (contourTuple == null)
//        //                {
//        //                    contourTuple = new HObject(temp.LineContours);
//        //                }
//        //                else
//        //                {
//        //                    contourTuple.ConcatObj(temp.LineContours);
//        //                }
//        //            }
//        //            HObject ho_Circle;
//        //            supTools.Arc_Concat(contourTuple, out ho_Circle, out hv_Row, out hv_Column, out hv_Radius);
//        //            outPut = new PlanElement(new Circle(new Point(hv_Row, hv_Column), hv_Radius, ho_Circle), ConstValue.CIRCLE);
//        //            break;
//        //        case ConstValue.MEASURE_CC_Cross:
//        //            leftCircle = Circle.FindItemByName(objectNameCollection[0], circleList);
//        //            rightCircle = Circle.FindItemByName(objectNameCollection[1], circleList);
//        //            supTools.CC_Cross(leftCircle.CircleContours, rightCircle.CircleContours, out hv_Row, out hv_Column);

//        //            for (int i = 0; i < hv_Row.TupleLength(); i++)
//        //            {
//        //                tempPoints.Add(new Point(hv_Row[i], hv_Column[i]));
//        //            }
//        //            outPut = new PlanElement(tempPoints, ConstValue.POINT);
//        //            break;
//        //        case ConstValue.MEASURE_CC_DIST:
//        //            leftCircle = Circle.FindItemByName(objectNameCollection[0], circleList);
//        //            rightCircle = Circle.FindItemByName(objectNameCollection[1], circleList);
//        //            HOperatorSet.DistanceCc(leftCircle.CircleContours, rightCircle.CircleContours, "point_to_point", out minDist, out maxDist);
//        //            double[] rs1 = { (double)minDist, (double)maxDist };
//        //            outPut = new PlanElement(rs1, ConstValue.DISTANCE);
//        //            break;
//        //        case ConstValue.MEASURE_CC_Mid:
//        //            leftCircle = Circle.FindItemByName(objectNameCollection[0], circleList);
//        //            rightCircle = Circle.FindItemByName(objectNameCollection[1], circleList);
//        //            HObject midCircleContour;
//        //            supTools.CC_Mid(leftCircle.CircleContours, rightCircle.CircleContours, out midCircleContour, out hv_Row, out hv_Column, out hv_Radius);
//        //            outPut = new PlanElement(new Circle(new Point(hv_Row, hv_Column), hv_Radius, midCircleContour), ConstValue.LINE);
//        //            break;

//        //        case ConstValue.MEASURE_C_Fit:
//        //            leftCircle = Circle.FindItemByName(objectNameCollection[0], circleList);
//        //            HObject fitCircleContours;
//        //            HOperatorSet.GetContourXld(leftCircle.CircleContours, out tempRow, out tempColumn);
//        //            supTools.C_Fit(out fitCircleContours, tempRow, tempColumn, out hv_Row, out hv_Column, out hv_Radius);
//        //            outPut = new PlanElement(new Circle(new Point(hv_Row, hv_Column), hv_Radius, fitCircleContours), ConstValue.CIRCLE);
//        //            break;
//        //        case ConstValue.MEASURE_C_RADIUS:
//        //            leftCircle = Circle.FindItemByName(objectNameCollection[0], circleList);
//        //            outPut = new PlanElement(leftCircle.Radius, ConstValue.RADIUS);
//        //            break;
//        //        case ConstValue.MEASURE_C_SUP:
//        //            HObject circleContours;
//        //            //待修正
//        //            supTools.C_SUP(out circleContours, 0, 0, 0);
//        //            break;
//        //        case ConstValue.MEASURE_LC_Cross:
//        //            leftLine = Line.FindItemByName(objectNameCollection[0], lineList);
//        //            rightCircle = Circle.FindItemByName(objectNameCollection[1], circleList);
//        //            supTools.LC_Cross(leftLine.LineContours, rightCircle.CircleContours, out hv_Row, out hv_Column);

//        //            for (int i = 0; i < hv_Row.TupleLength(); i++)
//        //            {
//        //                tempPoints.Add(new Point(hv_Row[i], hv_Column[i]));
//        //            }
//        //            outPut = new PlanElement(tempPoints, ConstValue.POINT);
//        //            break;
//        //        case ConstValue.MEASURE_LC_DIST:
//        //            leftLine = Line.FindItemByName(objectNameCollection[0], lineList);
//        //            rightCircle = Circle.FindItemByName(objectNameCollection[1], circleList);
//        //            HOperatorSet.FitLineContourXld(leftLine.LineContours, "turkey", -1, 0, 5, 2.0, out rowBegin, out colBegin, out rowEnd, out colEnd, out nr, out nc, out dist);
//        //            HOperatorSet.DistanceLc(rightCircle.CircleContours, rowBegin, colBegin, rowEnd, colEnd, out minDist, out maxDist);
//        //            double[] rs2 = { minDist, maxDist };
//        //            outPut = new PlanElement(rs2, ConstValue.DISTANCE);
//        //            break;
//        //        case ConstValue.MEASURE_LL_Concate:
//        //            foreach (var name in objectNameCollection)
//        //            {
//        //                Line line = Line.FindItemByName(name, lineList);
//        //                if (contourTuple == null)
//        //                {
//        //                    contourTuple = new HObject(line.LineContours);
//        //                }
//        //                else
//        //                {
//        //                    contourTuple.ConcatObj(line.LineContours);
//        //                }
//        //            }

//        //            supTools.LL_Concate(contourTuple, out concatLine, out rowBegin, out colBegin, out rowEnd, out colEnd);
//        //            outPut = new PlanElement(new Line(new Point(rowBegin, colBegin), new Point(rowEnd, colEnd)), ConstValue.LINE);
//        //            break;
//        //        case ConstValue.MEASURE_LL_Cross:
//        //            leftLine = Line.FindItemByName(objectNameCollection[0], lineList);
//        //            rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//        //            supTools.LL_Cross(leftLine.LineContours, rightLine.LineContours, out hv_Row, out hv_Column);
//        //            outPut = new PlanElement(new Point(hv_Row, hv_Column), ConstValue.POINT);
//        //            break;
//        //        case ConstValue.MEASURE_LL_Dist:
//        //            leftLine = Line.FindItemByName(objectNameCollection[0], lineList);
//        //            rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//        //            HTuple distance;
//        //            supTools.LL_Dist(leftLine.LineContours, rightLine.LineContours, out distance);
//        //            outPut = new PlanElement((double)distance, ConstValue.DISTANCE);
//        //            break;
//        //        case ConstValue.MEASURE_LL_InnerC:
//        //            foreach (var name in objectNameCollection)
//        //            {
//        //                Line line = Line.FindItemByName(name, lineList);
//        //                if (contourTuple == null)
//        //                {
//        //                    contourTuple = new HObject(line.LineContours);
//        //                }
//        //                else
//        //                {
//        //                    contourTuple.ConcatObj(line.LineContours);
//        //                }
//        //            }

//        //            supTools.LL_InnerC(contourTuple, out circleContours, out hv_Row, out hv_Column, out hv_Radius);
//        //            outPut = new PlanElement(new Circle(new Point(hv_Row, hv_Column), hv_Radius, circleContours), ConstValue.CIRCLE);
//        //            break;
//        //        case ConstValue.MEASURE_LL_Mid:
//        //            leftLine = Line.FindItemByName(objectNameCollection[0], lineList);
//        //            rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//        //            supTools.LL_Mid(leftLine.LineContours, rightLine.LineContours, out midLineContours, out rowBegin, out colBegin, out rowEnd, out colEnd);
//        //            outPut = new PlanElement(new Line(new Point(rowBegin, colBegin), new Point(rowEnd, colEnd)), ConstValue.LINE);
//        //            break;
//        //        case ConstValue.MEASURE_PC_DIST:
//        //            leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//        //            rightCircle = Circle.FindItemByName(objectNameCollection[1], circleList);
//        //            HOperatorSet.DistancePc(rightCircle.CircleContours, leftPoint.Row, leftPoint.Column, out minDist, out maxDist);
//        //            double[] rs = { minDist, maxDist };
//        //            outPut = new PlanElement(rs, ConstValue.DISTANCE);
//        //            break;
//        //        case ConstValue.MEASURE_PL_DIST:
//        //            leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//        //            rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//        //            HOperatorSet.FitLineContourXld(rightLine.LineContours, "turkey", -1, 0, 5, 2.0, out rowBegin, out colBegin, out rowEnd, out colEnd, out nr, out nc, out dist);
//        //            HOperatorSet.DistancePl(leftPoint.Row, leftPoint.Column, rowBegin, colBegin, rowEnd, colEnd, out distance);
//        //            outPut = new PlanElement((double)distance, ConstValue.DISTANCE);
//        //            break;
//        //        case ConstValue.MEASURE_PL_Mid:
//        //            leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//        //            rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//        //            supTools.PL_Mid(rightLine.LineContours, out midLineContours, leftPoint.Row, leftPoint.Column, out rowBegin, out colBegin, out rowEnd, out colEnd);
//        //            outPut = new PlanElement(new Line(rowBegin, colBegin, rowEnd, colEnd), ConstValue.LINE);
//        //            break;
//        //        case ConstValue.MEASURE_PL_Parallel:
//        //            leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//        //            rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//        //            supTools.PL_Parallel(rightLine.LineContours, leftPoint.Row, leftPoint.Column, out parallelContours, out rowBegin, out colBegin, out rowEnd, out colEnd);
//        //            outPut = new PlanElement(new Line(rowBegin, colBegin, rowEnd, colEnd), ConstValue.LINE);
//        //            break;
//        //        case ConstValue.MEASURE_PL_VERTICAL:
//        //            leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//        //            rightLine = Line.FindItemByName(objectNameCollection[1], lineList);
//        //            supTools.PL_VERTICAL(rightLine.LineContours, out verticalLineContours, leftPoint.Row, leftPoint.Column, out rowBegin, out colBegin, out rowEnd, out colEnd);
//        //            outPut = new PlanElement(new Line(rowBegin, colBegin, rowEnd, colEnd), ConstValue.LINE);
//        //            break;

//        //        case ConstValue.MEASURE_PP_DIST:
//        //            leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//        //            rightPoint = Point.FindItemByName(objectNameCollection[1], pointList);
//        //            HOperatorSet.DistancePp(leftPoint.Row, leftPoint.Column, rightPoint.Row, rightPoint.Column, out distance);
//        //            outPut = new PlanElement((double)distance, ConstValue.DISTANCE);
//        //            break;
//        //        case ConstValue.MEASURE_PP_Mid:
//        //            leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//        //            rightPoint = Point.FindItemByName(objectNameCollection[1], pointList);
//        //            supTools.PP_Mid(out midLineContours, leftPoint.Row, leftPoint.Column, rightPoint.Row, rightPoint.Column, out rowBegin, out colBegin, out rowEnd, out colEnd);
//        //            outPut = new PlanElement(new Line(rowBegin, colBegin, rowEnd, colEnd), ConstValue.LINE);
//        //            break;
//        //        case ConstValue.MEASURE_P_FitLine:

//        //            foreach (var name in objectNameCollection)
//        //            {
//        //                Point point = Point.FindItemByName(name, pointList);
//        //                if (tempRow == null)
//        //                {
//        //                    tempRow = new HTuple(point.Row);
//        //                    tempColumn = new HTuple(point.Column);
//        //                }
//        //                else
//        //                {
//        //                    tempRow.TupleConcat(point.Row);
//        //                    tempColumn.TupleConcat(point.Column);
//        //                }
//        //            }
//        //            supTools.P_FitLine(out fitLineContours, tempRow, tempColumn, out rowBegin, out colBegin, out rowEnd, out colEnd);
//        //            break;
//        //        case ConstValue.MEASURE_P_Mid:
//        //            leftPoint = Point.FindItemByName(objectNameCollection[0], pointList);
//        //            rightPoint = Point.FindItemByName(objectNameCollection[1], pointList);

//        //            break;

//        //    }

//        //    return outPut;
//        //}

//        public Object executeEnd()
//        {
//            return null;
//        }
//        public Circle get_circle(HObject image, HObject ROI)
//        {
//            Circle rsCircle = null;
//            HTuple minRadius =  (HTuple)args[ConstValue.MIN_RADIUS];
//            HTuple maxRadius = (HTuple)args[ConstValue.MAX_RADIUS];
//            HTuple minThreshold = (HTuple)args[ConstValue.MIN_THRESHOLD];
//            HTuple maxThreshold = (HTuple)args[ConstValue.MAX_THRESHOLD];
//            HOperatorSet.DispObj(ROI, Utils.hv_ExpDefaultWinHandle);
//            rsCircle = utils.Get_circle_fromROI(image, ROI, Utils.hv_ExpDefaultWinHandle, minRadius, maxRadius, minThreshold, maxThreshold);
//            return rsCircle;
//        }

//        public Hashtable generateHashtableForCircle(HTuple min_radius, HTuple max_radius, HTuple min_threshold, HTuple max_threshold)
//        {
//            Hashtable table = new Hashtable();
//            table.Add(ConstValue.MIN_RADIUS, new HTuple(min_radius));
//            table.Add(ConstValue.MAX_RADIUS, new HTuple(max_radius));
//            table.Add(ConstValue.MIN_THRESHOLD, new HTuple( min_threshold));
//            table.Add(ConstValue.MAX_THRESHOLD, new HTuple(max_threshold));
//            return table ;
//        }

//        public Hashtable generateHashtableForPoint(HTuple mode, HTuple minThreshold, HTuple maxThreshold)
//        {
//            Hashtable table = new Hashtable();
//            table.Add(ConstValue.MODE, new HTuple(mode));
//            table.Add(ConstValue.MIN_THRESHOLD, new HTuple(minThreshold));
//            table.Add(ConstValue.MAX_THRESHOLD, new HTuple(maxThreshold));
//            return table;
//        }

//        public Hashtable generateHashtableForLine(HTuple min_threshold, HTuple max_threshold)
//        {
//            Hashtable table = new Hashtable();
//            table.Add(ConstValue.MIN_THRESHOLD, new HTuple(min_threshold));
//            table.Add(ConstValue.MAX_THRESHOLD, new HTuple(max_threshold));
//            return table;
//        }

//        public  Line get_line(HObject image, HObject ROI)
//        {
//            Line rsLine = null;
//            HTuple minThreshold = (HTuple)args[ConstValue.MIN_THRESHOLD];
//            HTuple maxThreshold = (HTuple)args[ConstValue.MAX_THRESHOLD];
//            rsLine = utils.Get_line_fromROI(image, ROI, Utils.hv_ExpDefaultWinHandle, minThreshold, maxThreshold);
//            return rsLine;
//        }

//        public Point Get_Point(HObject image, HObject ROI)
//        {
//            Point rsPoint = null;
//            HTuple hv_RowStart, hv_RowEnd, hv_ColStart, hv_ColEnd,Nr,Nc,Dist;
//            HTuple hv_Mode = (HTuple)args[ConstValue.MODE];
//            HTuple minThreshold = (HTuple)args[ConstValue.MIN_THRESHOLD];
//            HTuple maxThreshold = (HTuple)args[ConstValue.MAX_THRESHOLD];
//            HOperatorSet.FitLineContourXld(ROI, "regression", -1, 0, 5, 1.5, out hv_RowEnd, out hv_ColEnd, out hv_RowStart, out hv_ColStart, out Nr, out Nc, out Dist);
//            rsPoint = utils.Get_point_fromLine(image,Utils.hv_ExpDefaultWinHandle, hv_Mode, hv_RowStart, hv_ColStart, hv_RowEnd, hv_ColEnd);
//            return rsPoint;
//        }

//        public Point Get_peakPoint(HObject image, HObject ROI)
//        {
//            Point rsPoint = null;
//            HTuple hv_Mode = (HTuple)args[ConstValue.MODE];
//            HTuple minThreshold = (HTuple)args[ConstValue.MIN_THRESHOLD];
//            HTuple maxThreshold = (HTuple)args[ConstValue.MAX_THRESHOLD];
//            rsPoint = utils.Get_peakPoint_fromROI(image,ROI, Utils.hv_ExpDefaultWinHandle, hv_Mode, minThreshold, maxThreshold);
//            return rsPoint;
//        }

//    }
//}
